<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use app\models\Company;
use app\models\Person;
use dosamigos\datepicker\DatePicker;

/* @var $this yii\web\View */
/* @var $model app\models\Park */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="park-form">

    <?php $form = ActiveForm::begin(); ?>

    <?php
    if($model->company_id!=0) {
        echo $form->field($model, 'company_id')->dropdownlist(
            Company::find()->select(['name'])->indexBy('id')->column(),
            ['prompt' => '选择所属公司', 'disabled' => 'disabled']);
    }else{
        echo  $form->field($model, 'company_id')->dropdownlist(
            Company::find()->select(['name'])->indexBy('id')->column(),
            ['prompt' => '选择所属公司']);
    }?>


    <!--?= $form->field($model, 'code')->textInput(['maxlength' => true]) ?-->

    <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'addr')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'scale')->textInput(['maxlength' => true]) ?>

    <!--?= $form->field($model, 'build_date')->textInput() ?-->

    <!--?= $form->field($model, 'start_date')->textInput() ?-->
    <!--?= DatePicker::widget([
        'model' => $model,
        'attribute' => 'start_date',
        'template' => '{addon}{input}',
        'clientOptions' => [
            'autoclose' => true,
            'format' => 'dd-M-yyyy'
        ]
    ]);?-->

    <?= $form->field($model, 'build_date')->widget(
        DatePicker::className(), [
        // inline too, not bad
        'inline' => true,
        // modify template for custom rendering
        'template' => '<div class="well well-sm" style="background-color: #fff; width:250px">{input}</div>',
        'clientOptions' => [
            'autoclose' => true,
            'format' => 'dd-M-yyyy'
        ]
    ]);?>

    <?= $form->field($model, 'start_date')->widget(
        DatePicker::className(), [
        // inline too, not bad
        'inline' => true,
        // modify template for custom rendering
        'template' => '<div class="well well-sm" style="background-color: #fff; width:250px">{input}</div>',
        'clientOptions' => [
            'autoclose' => true,
            'format' => 'dd-M-yyyy'
        ]
    ]);?>

    <?= $form->field($model, 'introduction')->textarea(['rows' => 6]) ?>

    <?= $form->field($model, 'tel')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'email')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'comment')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'map_image')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'qualification_image')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'pricipal_id')->dropdownlist(
        Person::find()->select(['name'])->indexBy('id')->column(),
        ['prompt' => '选择负责人']) ?>

    <?= $form->field($model, 'contact_id')->dropdownlist(
        Person::find()->select(['name'])->indexBy('id')->column(),
        ['prompt' => '选择联系人']) ?>

    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? '添加' : '更新', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
